window.pageTools = window.pageTools || {};
(function () {
    function Nav(superSelector, datas) {
        this.datas = datas || [];
        this.superView = $(superSelector || "");
        this.createView();
    }
    window.pageTools.Nav = Nav;

    Nav.prototype.createView = function(){
        var nav = $("<ul class='nav'></ul>");
        this.datas.forEach(function (info) {
            var item = $("<li class='nav_item' style='width:"+this.width/this.datas.length+"px'><a href='"+info.url+"'><img class='icon'src = '"+info.imageUrl+"' alt = '' > <span>"+info.title+"</span></a ></li > ");nav.append(item);
        }.bind(this));
        this.superView.append(nav);
    };

    // 主函数中初始化swiper
    var swiper = new Swiper('.swiper-container',
    {
        autoplay: true,
        pagination: {
            el: '.swiper-pagination',
        },
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },
    });

    // 主函数中动态创建轮播图
    images.forEach(function(item){
        var view = $("<div class='swiper-slide' style='background-image: url("+item+")'></div>");
        banners.append(view);
        
    })

       // 页面结构
    // 初始化分类类表
    new pageTools.TypeNav(".goods_type_container", datas, function (res) {
        console.log(res);
    });
    

   
})();